package cn.vehicle.controller;

import cn.vehicle.biz.TransportVehicleBiz;
import cn.vehicle.domains.vo.BasePage;
import cn.vehicle.domains.vo.Result;
import cn.vehicle.domains.vo.req.vehicle.AddTransportVehicleReq;
import cn.vehicle.domains.vo.req.vehicle.TransportVehicleListReq;
import cn.vehicle.domains.vo.req.vehicle.UpdateTransportVehicleReq;
import cn.vehicle.domains.vo.res.vehicle.TransportVehicleRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/transport-vehicle") // 与其他接口路径规范一致，前缀为/api/transport-vehicle
@Slf4j
@Tag(name = "TransportVehicleController", description = "运输车辆管理相关接口")
public class TransportVehicleController {

    @Resource
    private TransportVehicleBiz transportVehicleBiz;

    @PostMapping("/add")
    @Operation(description = "新增运输车辆接口")
    public Result<Void> addTransportVehicle(@RequestBody @Valid AddTransportVehicleReq req) {
        transportVehicleBiz.addTransportVehicle(req);
        return Result.success();
    }

    @PostMapping("/update")
    @Operation(description = "更新运输车辆接口")
    public Result<Void> updateTransportVehicle(@RequestBody @Valid UpdateTransportVehicleReq req) {
        transportVehicleBiz.updateTransportVehicle(req);
        return Result.success();
    }

    @PostMapping("/delete")
    @Operation(description = "删除单个运输车辆接口")
    public Result<Void> deleteTransportVehicle(
            @Parameter(schema = @Schema(name = "id", description = "运输车辆ID"))
            @RequestParam Long id) {
        transportVehicleBiz.deleteTransportVehicle(id);
        return Result.success();
    }


    @PostMapping("/get-by-id")
    @Operation(description = "查询运输车辆详情接口")
    public Result<TransportVehicleRes> getTransportVehicleById(
            @Parameter(schema = @Schema(name = "id", description = "运输车辆ID"))
            @RequestParam Long id) {
        return Result.success(transportVehicleBiz.getTransportVehicleById(id));
    }

    @PostMapping("/list")
    @Operation(description = "分页查询运输车辆列表接口")
    public Result<BasePage<TransportVehicleRes>> listTransportVehicles(@RequestBody @Valid TransportVehicleListReq req) {
        return Result.success(transportVehicleBiz.listTransportVehicles(req));
    }
}